package com.tepth.busfix.main.alarm;

import com.tepth.busfix.bean.reponse.AlarmType;
import com.tepth.busfix.network.ApiModel;
import com.tepth.busfix.network.observer.SimpleDisposableObserver;

import java.util.List;

/**
 * Created by TMVPHelper on 2017/03/21
 */
public class AlarmInfoPresenter extends AlarmInfoContract.Presenter {

    @Override
    void getAlarmInfo() {
        mRxManager.add(mModel.getAlarmInfo(mView.getAuthKey(), mView.getVehicleId())
                .subscribeWith(new SimpleDisposableObserver<ApiModel<List<AlarmType>>>(mView) {

                    @Override
                    public void onSucceed(Object o) {
                        List<AlarmType> list = (List<AlarmType>) o;
                        mView.showAlarmTypes(list);
                    }
                }));
    }

    @Override
    void getAlarmInfoByTroubleTypeId() {
        mRxManager.add(mModel.getAlarmInfoById(mView.getAuthKey(), mView.getVehicleId(),mView.getTroubleTypeId())
                .subscribeWith(new SimpleDisposableObserver<ApiModel<List<AlarmType>>>(mView) {

                    @Override
                    public void onSucceed(Object o) {
                        List<AlarmType> list = (List<AlarmType>) o;
                        mView.showAlarmTypes(list);
                    }
                }));
    }
}